package com.kuaiyin.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import com.kuaiyin.sampling.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.io.Serializable;
import java.util.Map;

/**
 * <p>
 * JMeter HTTP请求配置表
 * </p>
 *
 * @author ng
 * @since 2025-06-23
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName(value = "jmeter_http_request", autoResultMap = true)
@Schema(name = "JmeterHttpRequest", description = "JMeter HTTP请求配置表")
public class JmeterHttpRequest extends BaseEntity implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(description = "主键ID")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @Schema(description = "所属测试ID")
    private Integer jmeterTestId;

    @Schema(description = "请求名称")
    private String name;

    @Schema(description = "协议（http/https）", allowableValues = {"http", "https"})
    private String protocol;

    @Schema(description = "域名/IP")
    private String domain;

    @Schema(description = "端口（0表示默认）")
    private Integer port;

    @Schema(description = "请求路径")
    private String path;

    @Schema(description = "请求方法", allowableValues = {"GET", "POST", "PUT", "DELETE", "PATCH"})
    private String method;

    @Schema(description = "请求头（JSON）")
    @TableField(typeHandler = FastjsonTypeHandler.class)
    private Map<String, Object> headers;

    @Schema(description = "URL参数（JSON）")
    @TableField(typeHandler = FastjsonTypeHandler.class)
    private Map<String, Object> parameters;

    @Schema(description = "请求体（JSON字符串）")
    @TableField(typeHandler = FastjsonTypeHandler.class)
    private Map<String, Object> body;

    @Schema(description = "超时时间（毫秒）")
    private Integer timeout;

    @Schema(description = "是否跟随重定向")
    private Boolean followRedirects;

    @Schema(description = "是否保持连接")
    private Boolean keepAlive;

}
